package com.wujp.common.template.tools.factory;

import com.wujp.common.template.tools.enums.BeanType;
import com.wujp.common.template.tools.model.template.BaseTemplateModel;
import com.wujp.common.template.tools.interfaces.BeanFactory;
import com.wujp.common.template.tools.interfaces.TemplateLoader;

import java.util.Map;

/**
 * @desc: 模板的模型bean工厂
 * @author: wujp
 * @create: 2023-01-18 15:58
 */
public class TemplateBeanFactory implements BeanFactory {

    private TemplateLoader templateLoader;

    @Override
    public <T> T getBean(String beanName) {
        Map<String, BaseTemplateModel> templateModels = templateLoader.loadTemplates();
        return (T) templateModels.get(beanName);
    }

    @Override
    public String bindingBeanType() {
        return BeanType.TEMPLATE_BEAN.getType();
    }
}
